<template>
	<div class="index-page">
		<router-view></router-view>
		<van-tabbar v-model="active1">
		  <van-tabbar-item name="home" icon="home-o">首页</van-tabbar-item>
		  <van-tabbar-item name="shop" icon="logistics">商城</van-tabbar-item>
		  <van-tabbar-item name="activity" icon="discount">活动</van-tabbar-item>
		  <van-tabbar-item name="me" icon="user-o">我的</van-tabbar-item>
		</van-tabbar>
	</div>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
	export default{
		data(){
			return {
				active1:''
			}
		},
		computed:{
			...mapState(['active'])
		},
		methods:{
			...mapMutations(['setActive']),
			jump(v){
				if(this.$route.path != '/'+v){
					this.$router.push('/'+v)
				}
			}
		},
		watch:{
			active1(v){
				this.setActive(v)
				this.jump(v)
			},
			active(v){
				this.active1 = v
			}
		},
		created(){
			let active = sessionStorage.active
			
			if(active){
				this.active1 = active
				// this.$router.push('/'+active)
			}else{
				this.active1 = this.active
				this.jump(this.active1)
			}
		}
	}
</script>

<style lang="scss">
	.index-page{
		padding-bottom: 50px;
	}
</style>
